package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cheer.entity.Account;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Mapper
@Repository
public interface AccountDao extends BaseMapper<Account> {

    default List<Account> listByAccount(String account) {
        return selectList(new QueryWrapper<Account>()
                .eq("phone", account)
                .or()
                .eq("backup_account", account));
    }

    default List<Account> listByRoleIds(ArrayList<Integer> accounts){


        QueryWrapper<Account> accountQueryWrapper = new QueryWrapper<>();
        accountQueryWrapper.lambda().in(Account::getRole, accounts);

        return selectList(accountQueryWrapper);
    }
}
